package TestSystemUtil;

import java.util.*;

public class Protocol {
	
	public ArrayList<String> analyseMessageFromClient (String message) {
		StringTokenizer tokenizer = new StringTokenizer(message, "+");
		ArrayList<String> result = new ArrayList<String>();
	
		switch(tokenizer.nextToken()) {
		case "LOGIN": 
			result.add("LOGIN");
			break;
		case "REGISTER":
			result.add("REGISTER");
			break;
		case "PLAY":
			result.add("PLAY");
			break;
		case "LOGOUT":
			result.add("LOGOUT");
			break;
		case "EXIT":
			result.add("EXIT");
			break;
		case "INVITE":
			result.add("INVITE");
			break;
		case "ACCEPT":
			result.add("ACCEPT");
			break;
		case "DECLINE":
			result.add("DECLINE");
			break;
		case "LEAVEGROUP":
			result.add("LEAVEGROUP");
			break;
		case "GROUPPLAY":
			result.add("GROUPPLAY");
			break;
		case "GROUPSUBMIT":
			result.add("GROUPSUBMIT");
			break;
		case "GET_HIGHSCORE":
			result.add("GET_HIGHSCORE");
			break;
		case "INTERRUPT":
			result.add("INTERRUPT");
			break;
		case "SINGLESUBMIT":
			result.add("SINGLESUBMIT");
			break;
		case "GET_HISTORY":
			result.add("GET_HISTORY");
			break;
		}
		while(tokenizer.hasMoreTokens()) result.add(tokenizer.nextToken());
		return result;
	}

}
